
<!--
  /**************************************************
  * @ orderinputnewbatch.jsp
  *
  *    Copyright (c) 2007-2008 Shanghai Auto-Parts E-Procurement Co., Ltd. 
  *        All rights reserved.
  *
  * Modify History:
  *  v1.00, 2008/07/09, john
  *  1) first release,新增批次订单
  /**************************************************
-->
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ include file="../../common.jsp"%>
<html>
<head>
<title>新增批次订单</title>
<META http-equiv=Content-Type content="text/html; charset=UTF-8">
<LINK href="<%=root%>/css/caigouxitong.css" " type=text/css rel=stylesheet>
<SCRIPT language="JavaScript" src="<%=root%>/js/common.js"></SCRIPT>
<SCRIPT language="JavaScript" src="<%=root%>/js/calendar.js"></SCRIPT>
<SCRIPT language="JavaScript" src="<%=root%>/js/string.js"></SCRIPT>
<SCRIPT language="JavaScript" src="<%=root%>/js/hi-check.js"></SCRIPT>
<SCRIPT language="JavaScript" src="<%=root%>/js/func.js"></SCRIPT>

<%
    ArrayList tNewBatchList = (ArrayList)request.getAttribute("newbatchlist");

%>

<script>

function LTrim(s)
{ 
    for(var i=0;i<s.length;i++)
    {
      if(s.charAt(i)!=" ")
      {
          return s.substr(i,s.length-i);
      }
   }
   return "";
}
function RTrim(s)
{ 
    for(var i=s.length-1;i>=0;i--)
    {
      if(s.charAt(i)!=" ")
      {
          return s.substr(0,i+1);
      }
   }
   return "";
}
function Trim(s)
{
    return  RTrim(LTrim(s));
}

//判断一个字符串是否为空字符串
function isEmpty(s)
{
    return ""==Trim(s);
}

var seleall=false;
function selectall(seleall){
    var f = document.listform;
    if(seleall){
      for (i=0;i<f.elements.length;i++){
          if (f.elements[i].name=="orderDetailIds")
              f.elements[i].checked =true;
      }
    } else {
      for (i=0;i<f.elements.length;i++){
          if (f.elements[i].name=="orderDetailIds")
              f.elements[i].checked =false;
      }
  }
}

function process(){
  var selectedLine=0;
  if(document.listform.orderDetailIds.length > 1){
    var selectedDetailIds = document.listform.orderDetailIds;

    for(i=0; i<selectedDetailIds.length;i++){
        if(document.listform.orderDetailIds[i].checked){
            if(isEmpty(document.listform.orderCount[i].value) || 
            isNumber(document.listform.orderCount[i].value) == false || 
            parseFloat(document.listform.orderCount[i].value) <=0)
            {
                alert("请填写签收数量，签收数量必须大于0!");
                document.listform.orderCount[i].value = document.listform.maxOrderCount[i].value;
                return false;
            }
            if(parseFloat(document.listform.orderCount[i].value) > parseFloat(document.listform.maxOrderCount[i].value)){
                alert("签收数量必须大于0,小于等于!"+ document.listform.maxOrderCount[i].value+"!");
                document.listform.orderCount[i].value = document.listform.maxOrderCount[i].value;
                return false;
            }

            if(isEmpty(document.listform.deliverdate[i].value)){
                alert("请选择签收日期!");
                return false;
            }
            selectedLine++;
            submitform.orderDetailId[i].checked = true;
            submitform.orderDetailId[i].value = listform.orderDetailId[i].value;
            submitform.concentricityId[i].checked = true;
            submitform.concentricityId[i].value = listform.concentricityId[i].value;
            submitform.manufName[i].checked = true;
            submitform.manufName[i].value = listform.manufName[i].value;                                                                
            submitform.providerName[i].checked = true;
            submitform.providerName[i].value = listform.providerName[i].value;
            submitform.manufSpec[i].checked = true;
            submitform.manufSpec[i].value = listform.manufSpec[i].value;                               
            submitform.manufType[i].checked = true;
            submitform.manufType[i].value = listform.manufType[i].value;                                
            submitform.manufBrand[i].checked = true;
            submitform.manufBrand[i].value = listform.manufBrand[i].value;                                
            submitform.orderCount[i].checked = true;
            submitform.orderCount[i].value = listform.orderCount[i].value; 
            submitform.deliverdate[i].checked = true;
            submitform.deliverdate[i].value = document.getElementById("deliverdate"+i).value;   
            submitform.quantUnit[i].checked = true;
            submitform.quantUnit[i].value = listform.quantUnit[i].value;
         }
      }
  } else {
          if(document.listform.orderDetailIds.checked){
            if(isEmpty(document.listform.orderCount.value) ||
            isNumber(document.listform.orderCount.value) == false || 
            parseFloat(document.listform.orderCount.value) <=0 )
            {
                alert("请填写签收数量，签收数量必须大于0!");
                document.listform.orderCount.value = document.listform.maxOrderCount.value;
                return false;
            }
            if(parseFloat(document.listform.orderCount.value) > parseFloat(document.listform.maxOrderCount.value)){
                alert("签收数量必须大于0,小于等于"+ document.listform.maxOrderCount.value+"!");
                document.listform.orderCount.value = document.listform.maxOrderCount.value;
                return false;
            }
            if(isEmpty(document.listform.deliverdate.value)){
                alert("请选择签收日期!");
                return false;
            }
            selectedLine++;
            submitform.orderDetailId.checked = true;
            submitform.orderDetailId.value = listform.orderDetailId.value;
            submitform.concentricityId.checked = true;
            submitform.concentricityId.value = listform.concentricityId.value;
            submitform.manufName.checked = true;
            submitform.manufName.value = listform.manufName.value;                                                                
            submitform.providerName.checked = true;
            submitform.providerName.value = listform.providerName.value;
            submitform.manufSpec.checked = true;
            submitform.manufSpec.value = listform.manufSpec.value;                               
            submitform.manufType.checked = true;
            submitform.manufType.value = listform.manufType.value;                                
            submitform.manufBrand.checked = true;
            submitform.manufBrand.value = listform.manufBrand.value;                                
            submitform.orderCount.checked = true;
            submitform.orderCount.value = listform.orderCount.value; 
            submitform.deliverdate.checked = true;
            submitform.deliverdate.value = document.getElementById("deliverdate0").value;   
            submitform.quantUnit.checked = true;
            submitform.quantUnit.value = listform.quantUnit.value;
         }
  
  }
    if(selectedLine<1){
        alert("请至少选择一笔订单");
        return false;
    }
    
    if(confirm("是否确定要创建所选的批次订单？")){ 
      submitform.action = "<%=response.encodeURL(request.getContextPath()+"/A101305.do")%>" ;
      submitform.submit();  
    }else{
        return false;
    }  

          
}
</script>
</head>

<body BGCOLOR="#f2f2f2" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<center>
<form name="listform" method="post">
<table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
  <td class="mtxt_black">你所提交的签收数量会导致部分订单未满额签收，是否要对这些订单创建新的批次？</td>
  <tr>
    <td>
    <table class=bg_table id=tableId cellspacing=1 cellpadding=2 width=100% align=center border=0>
      <tbody>
        <tr class="bg_column" height=20>
          <td class=top align=center colspan="18">
          <div align="center" class="txt_content"><b>可创建的批次订单列表</b></div>
          </td>
        </tr>
        <tr class="bg_column" height=20>
          <td class=top align=center><input type="checkbox" onclick=selectall(this.checked) id="orderAllselect" name="orderAllselect"></td>
          <td class=top align=center>
          <div align="center" class="txt_content">申购单明细编号</div>
          </td>

          <td class=top align=center>
          <div align="center" class="txt_content">集中编码</div>
          </td>

          <td class=top align=center>
          <div align="center" class="txt_content">产品名称</div>
          </td>

          <td class=top align=center>
          <div align="center" class="txt_content">供应商</div>
          </td>

          <td class=top align=center>
          <div align="center" class="txt_content">规格</div>
          </td>

          <td class=top align=center>
          <div align="center" class="txt_content">型号</div>
          </td>

          <td class=top align=center>
          <div align="center" class="txt_content">品牌</div>
          </td>

          <td class=top align=center>
          <div align="center" class="txt_content">订货数量</div>
          </td>

          <td class=top align=center>
          <div align="center" class="txt_content">要求送货时间</div>
          </td>

          <td class=top align=center>
          <div align="center" class="txt_content">订货单位</div>
          </td>

        </tr>
        <%
            for (int i = 0; i < tNewBatchList.size(); i++) {
                GSOrderDetailModifyVO tGSOrderDetailModifyVO = (GSOrderDetailModifyVO)tNewBatchList.get(i);
                String tTempStr = "";
                if (i % 2 == 0) {
                    tTempStr = "class=\"bg_row_odd\"";
                }
                else {
                    tTempStr = "class=\"bg_row_even\"";
                }
        %>

        <tr <%=tTempStr%> height=20>
          <td class=top>
          <div align="center" class="txt_content">
          <input type="checkbox" id="orderDetailIds" name="orderDetailIds">
          </div>
          </td>
          <td class=top align=center>
          <div align="center" class="txt_content"><%=tGSOrderDetailModifyVO.orderDetailId%></div>
          <input id='orderDetailId' name='orderDetailId' type="hidden" value="<%=tGSOrderDetailModifyVO.orderDetailId%>"></td>

          <td class=top align=center>
          <div align="center" class="txt_content"><%=tGSOrderDetailModifyVO.concentricityId%></div>
          <input id='concentricityId' name='concentricityId' type="hidden" value="<%=tGSOrderDetailModifyVO.concentricityId%>"></td>

          <td class=top align=center>
          <div align="center" class="txt_content"><%=tGSOrderDetailModifyVO.manufName%></div>
          <input id='manufName' name='manufName' type="hidden" value="<%=tGSOrderDetailModifyVO.manufName%>"></td>

          <td class=top align=center>
          <div align="center" class="txt_content"><%=tGSOrderDetailModifyVO.providerName%></div>
          <input id='providerName' name='providerName' type="hidden" value="<%=tGSOrderDetailModifyVO.providerName%>"></td>

          <td class=top align=center>
          <div align="center" class="txt_content"><%=tGSOrderDetailModifyVO.manufSpec%></div>
          <input id='manufSpec' name='manufSpec' type="hidden" value="<%=tGSOrderDetailModifyVO.manufSpec%>"></td>

          <td class=top align=center>
          <div align="center" class="txt_content"><%=tGSOrderDetailModifyVO.manufType%></div>
          <input id='manufType' name='manufType' type="hidden" value="<%=tGSOrderDetailModifyVO.manufType%>"></td>

          <td class=top align=center>
          <div align="center" class="txt_content"><%=tGSOrderDetailModifyVO.manufBrand%></div>
          <input id='manufBrand' name='manufBrand' type="hidden" value="<%=tGSOrderDetailModifyVO.manufBrand%>"></td>

          <td class=top align=center>
          <div align="center" class="txt_content">
          <input name="orderCount" id="orderCount" type="text" size="4" value="<%=StringUtils.formatEDouble(tGSOrderDetailModifyVO.orderCount,2)%>"></div>
          <input id='maxOrderCount' name='maxOrderCount' type="hidden" value="<%=StringUtils.formatEDouble(tGSOrderDetailModifyVO.orderCount,2)%>">
          </td>
          
          <td class=top align=center>
          <div align="center" class="txt_content">
          <input type="text" id='deliverdate<%=i %>' name='deliverdate' size="12" readonly
            onfocus='setday(this,document.getElementById("deliverdate<%=i %>"))'></div>
          </td>

          <td class=top align=center>
          <div align="center" class="txt_content"><%=tGSOrderDetailModifyVO.quantUnit%></div>
          <input id='quantUnit' name='quantUnit' type="hidden" value="<%=tGSOrderDetailModifyVO.quantUnit%>"></td>

        </tr>
        <%
            }
        %>
      </tbody>
    </table>
    </td>
  </tr>
</table>
</form>
</center>

    <form name="submitform" method="post">
        <div style='display:none'>      
    <%
        if(tNewBatchList != null && tNewBatchList.size() > 0){  
            for(int i=0; i< tNewBatchList.size();i++){
    %>

    <input type="checkbox" name="orderDetailId">
    <input type="checkbox" name="concentricityId">          
    <input type="checkbox" name="manufName"> 
    <input type="checkbox" name="providerName">
    <input type="checkbox" name="manufSpec">
    <input type="checkbox" name="manufType">
    <input type="checkbox" name="manufBrand">   
    <input type="checkbox" name="orderCount">    
    <input type="checkbox" name="deliverdate">
    <input type="checkbox" name='quantUnit'>  
    <%              
            }
        }
    %>
    </div>
    </form>
    
<p align="center"><input type="button" class="kuang" value="确认" onClick="process()"> <input type="button" class="kuang" value="取消" onclick="history.back(1);">
<br />
<br />
<br />
<br />
</p>

</body>
</html>